<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <a id="myAnchor" href="https://developer.mozilla.org/zh-CN/docs/Web/API/Location/search"></a>
    <script>
        // location.assign("http://www.baidu.com");

        // location.replace("https://www.bilibili.com/video/BV1ca4y1i7Lz/?spm_id_from=333.337.search-card.all.click&vd_source=14f845d15ed0c9eae38c9124e30f90b2"); // replace会刷新页面   


        // location.href = "http://www.baidu.com"; // 等同于location.assign("http://www.baidu.com");


        // location.reload(); // 刷新当前页面

        // location.toString()
        // location.replace
        // 假设文档中有一个 <a id="myAnchor" href="/en-US/docs/Location.search?q=123"> 元素
        const anchor = document.getElementById("myAnchor");
        const queryString = anchor.search; // 返回：'?q=123'
        console.log(queryString);

        // 保证DOM事件在window.onload之前执行
        window.onload

    </script>
</body>

</html>